package com.tza.web.t_net.client.data;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;

public class MTreeDataSource extends DataSource
{

   private static MTreeDataSource instance = null;

   public static MTreeDataSource getInstance()
   {
      if (instance == null)
      {
         instance = new MTreeDataSource("supplyCategoryDS");
      }
      return instance;
   }

   public MTreeDataSource(String id)
   {

      setID(id);
      setRecordXPath("/List/supplyCategory");

      DataSourceTextField itemNameField = new DataSourceTextField("categoryName", "Item", 128, true);
      itemNameField.setPrimaryKey(true);

      DataSourceTextField parentField = new DataSourceTextField("parentID", null);
      parentField.setHidden(true);
      parentField.setRequired(true);
      parentField.setRootValue("root");
      parentField.setForeignKey("supplyCategoryDS.categoryName");

      setFields(itemNameField, parentField);

      setDataURL("ds/test_data/supplyCategory.data.xml");

      setClientOnly(true);

   }
}
